package com.sc.ktapplication.common.util

import com.sc.ktapplication.common.constant.MMKVConstant
import com.tencent.mmkv.MMKV

object MMKVUtil {

    private val kv = MMKV.defaultMMKV()

    fun putString(key : String,value : String?){
        kv!!.encode(key,value)
    }

    fun getString(key : String):String?{
        return kv!!.decodeString(key)
    }

    fun putBool(key : String,value : Boolean){
        kv!!.encode(key,value)
    }

    fun getBool(key : String) : Boolean{
        return kv!!.decodeBool(key)
    }

    fun putInt(key : String,value : Int){
        kv!!.encode(key,value)
    }

    fun getInt(key : String) : Int{
        return kv!!.decodeInt(key)
    }

    fun clearCache(){
        putString(MMKVConstant.APP_USER,null)
    }
}